home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieStopklatka.py < prev    next >
Text File  |  2008-11-17  |  4KB  |  136 lines

  1. # -*- coding: utf-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieStopklatka.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2008 Piotr O┼╝arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils, movie
  25. import string, re
  26.  
  27. plugin_name         = 'Stopklatka'
  28. plugin_description  = 'Internetowy Serwis Filmowy'
  29. plugin_url          = 'www.stopklatka.pl'
  30. plugin_language     = _('Polish')
  31. plugin_author       = 'Piotr O┼╝arowski'
  32. plugin_author_email = '<ozarow+griffith@gmail.com>'
  33. plugin_version      = '1.9'
  34.  
  35. class Plugin(movie.Movie):
  36.     IMAGE_PATTERN = re.compile('(http://img.stopklatka.pl/film/.*?)"')
  37.  
  38.     def __init__(self, id):
  39.         self.movie_id = id
  40.         self.url = "http://www.stopklatka.pl/film/film.asp?fi=%s" % str(self.movie_id)
  41.         self.encode = 'iso-8859-2' # with some cp-1250 data (sic!)
  42.  
  43.     def initialize(self):
  44.         self.page = self.page.replace('\x9c','┼¢')
  45.         self.page = self.page.replace('┼í','─à')
  46.  
  47.     def get_image(self):
  48.         image = self.IMAGE_PATTERN.findall(self.page)
  49.         if len(image):
  50.             self.image_url = image[0]
  51.  
  52.     def get_o_title(self):
  53.         self.o_title = gutils.trim(self.page, '<h2> (', ')</h2>')
  54.         if self.o_title == '':
  55.             self.o_title = self.get_title(True)
  56.  
  57.     def get_title(self, ret=False):
  58.         data = gutils.trim(self.page, '<h1>', '</h1>')
  59.         if ret is True:
  60.             return data
  61.         else:
  62.             self.title = data
  63.  
  64.     def get_director(self):
  65.         self.director = gutils.trim(self.page, '>re\xbfyseria:<', '</td></tr>')
  66.         self.director = gutils.after(self.director, '>')
  67.  
  68.     def get_plot(self):
  69.         self.plot = gutils.trim(self.page, '<p>', '</p>')
  70.         self.plot = gutils.before(self.plot, '<b>Wi\xEAcej ')
  71.  
  72.     def get_year(self):
  73.         self.year = gutils.trim(self.page, '>rok produkcji:<', '</span>')
  74.         self.year = gutils.after(self.year, '>')
  75.  
  76.     def get_runtime(self):
  77.         self.runtime = gutils.trim(self.page, 'trwania:<', ' min<')
  78.         self.runtime = gutils.after(self.runtime, '>')
  79.  
  80.     def get_genre(self):
  81.         self.genre = gutils.trim(self.page, '>gatunek:<', '</span>')
  82.         self.genre = gutils.after(self.genre, '>')
  83.  
  84.     def get_cast(self):
  85.         self.cast = gutils.trim(self.page, '>obsada:<', '</td></tr>')
  86.         self.cast = gutils.after(self.cast, '>')
  87.         self.cast = string.replace(self.cast, ', ', "\n")
  88.         self.cast = gutils.before(self.cast, '<b>Wi\xEAcej ')
  89.  
  90.     def get_classification(self):
  91.         self.classification = ''
  92.  
  93.     def get_studio(self):
  94.         self.studio = ""
  95.  
  96.     def get_o_site(self):
  97.         self.o_site = gutils.trim(self.page,">strona oficjalna:<"," target=_blank")
  98.         self.o_site = gutils.after(self.o_site,"href=")
  99.  
  100.     def get_site(self):
  101.         self.site = self.url
  102.  
  103.     def get_trailer(self):
  104.         self.trailer = "http://www.stopklatka.pl/film/film.asp?fi=" + self.movie_id + "&sekcja=mmedia"
  105.  
  106.     def get_country(self):
  107.         self.country = gutils.trim(self.page, '>kraj:<', '</span>')
  108.         self.country = gutils.after(self.country, '>')
  109.  
  110.     def get_rating(self):
  111.         self.rating = '0'
  112.  
  113.     def get_notes(self):
  114.         self.notes = ''
  115.  
  116. class SearchPlugin(movie.SearchMovie):
  117.     def __init__(self):
  118.         self.encode='iso-8859-2'
  119.         self.original_url_search    = "http://www.stopklatka.pl/szukaj/szukaj.asp?kategoria=film&szukaj="
  120.         self.translated_url_search    = "http://www.stopklatka.pl/szukaj/szukaj.asp?kategoria=film&szukaj="
  121.  
  122.     def search(self,parent_window):
  123.         self.open_search(parent_window)
  124.         self.page = gutils.trim(self.page, '>Wyniki poszukiwania frazy:', '</div>');
  125.         self.page = self.page.replace('\x9c','┼¢')
  126.         self.page = self.page.replace('┼í','─à')
  127.         return self.page
  128.  
  129.     def get_searches(self):
  130.         elements = re.findall("""/film/film.asp\?fi=(\d+)">.*?searchTitle\s*textB">(.*?)</span""", self.page)
  131.         self.number_results = len(elements)
  132.  
  133.         for element in elements:
  134.             self.ids.append(element[0])
  135.             self.titles.append(element[1])
  136.